<?php
require_once WEB_ROOT. '/application/library/Bus.php';

class Bus_Product extends Bus {
    protected $_name = "products";
    
    protected function _init() {
        
    }
    
    public function getNewProduct($qty=0) {
        return $this->select(array(
            'fields' => array(),
            'order'  => "import_date DESC",
            'limit'  => "0,{$qty}"
        ));
    }
    
    public function getBestSell($qty=0) {
        return $this->select(array(
            'fields'  => array(),
            'order'   => "qtysold DESC",
            'limit'   => "0,{$qty}"
        ));
    }
    
    public function getProductWithId($id) {
        $dto = $this->select(array(
            'fields'   => array(),
            'where'    => "id='{$id}'"
        ));
        if(count($dto) > 0) {
            return $dto[0];
        }
        return false;
    }    
}
?>